﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tanmia.Warehouse.Core;
using FluentNHibernate.Mapping;

namespace Tanmia.Warehouse.NHibernateRepository.Mapping
{
    public class ItemMap : ClassMap<Item>
    {
        public ItemMap()
        {
            Table("Item");

            Id(x => x.ElementID, "ItemID").Not.Nullable().GeneratedBy.Identity().Unique();

            Map(x => x.Name).Not.Nullable().Length(50);
            Map(x => x.EngName).Length(50);
            Map(x => x.Code).Length(50);
            Map(x => x.Number).Length(50).Not.Nullable();

            Map(x => x.Description);
            Map(x => x.ItemBarcode);
            Map(x => x.StopInput);
            Map(x => x.StopOutput);
            Map(x => x.BalanceExceeding);
            Map(x => x.Minimum);
            Map(x => x.Maximum);

            References(x => x.MovingApproach);
            References(x => x.Category, "CategoryID").Nullable();
            HasMany<ItemUnit>(x => x.ItemUnits).KeyColumn("ItemID").Inverse();
        }
    }
}
